import requests


class IhrmDepartApi:

    #封装添加部门的方法
    @classmethod
    def add_api(cls,token, add_body):
        add_url = "http://ihrm-test.itheima.net/api/company/department"
        add_header = {"Content-Type": "application/json", "Authorization": token}
        add_resp = requests.post(url=add_url, headers=add_header, json=add_body)
        return add_resp
    # 封装查询部门的方法
    @classmethod
    def find_api(cls, depart_id, token):
        find_url = f"http://ihrm-test.itheima.net/api/company/department/{depart_id}"
        find_header = {"Authorization": token}
        find_resp = requests.get(url=find_url, headers=find_header)
        return find_resp

    #封装修改部门的方法
    @classmethod
    def update_api(cls, depart_id, token, update_body):
        update_url = f"http://ihrm-test.itheima.net/api/company/department/{depart_id}"
        update_header = {"Content-Type": "application/json", "Authorization": token}
        update_resp = requests.put(url=update_url, headers=update_header, json=update_body)
        return update_resp
    #封装删除部门的方法
    @classmethod
    def delete_api(cls, depart_id, token):
        delete_url = f"http://ihrm-test.itheima.net/api/company/department/{depart_id}"
        delete_header = {"Authorization": token}
        delete_resp = requests.delete(url=delete_url, headers=delete_header)
        return delete_resp





